package com.winning.sx.microframework.common.util;

/**
 * 权限状态
 * Created by Kong on 2019-02-20.
 */
public enum GrantState {

	TOKEN_EXPIRED("token过期"),
	TOKEN_INVALID("token无效"),
	NO_TOKEN("未携带token"),
	NO_ROLE("未授权，您没有权限访问"),
	NO_MATCH("uid密钥不匹配"),
	OK("通过");

	private String state;

	private GrantState(String state) {
		this.state = state;
	}

	public String getState() {
		return state;
	}

	public void setState(String state) {
		this.state = state;
	}

	/**
	 * 根据状态字符串获取状态枚举对象
	 */
	public static GrantState getTokenState(String tokenState) {
		GrantState[] states = GrantState.values();
		GrantState ts = null;
		for (GrantState state : states) {
			if (state.toString().equals(tokenState)) {
				ts = state;
				break;
			}
		}
		return ts;
	}
}
